//
//  MainViewController.swift
//  WB
//
//  Created by leador on 17/3/17.
//  Copyright © 2017年 袁满. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    
    lazy var composeBtn:UIButton = UIButton(image:"tabbar_compose_icon_add",backgroundImage:"tabbar_compose_button")

    override func viewDidLoad() {
        super.viewDidLoad()
        
        setComposeBtn()
        
    }
}

//MARK: ---UI界面---
extension MainViewController {
    
    func setComposeBtn() {
        //添加按钮
        tabBar.addSubview(composeBtn)
        
        composeBtn.center = CGPoint(x:tabBar.center.x,y:tabBar.bounds.size.height*0.5)
        
        //添加点击
        composeBtn.addTarget(self, action: #selector(MainViewController.composeBtnClick), for: .touchUpInside)

    }
}

//MARK: ---事件的监听---
extension MainViewController {
    
    //将方法包装成@SEl--->类中查找方法列表--->根据@SEl查找对应的imp指针---->执行函数
    //被private修饰的方法不会添加到方法列表中
    //如在private前面加上@objc，则该方法依然会添加到方法列表中
    func composeBtnClick() {
        
        let composeVC = ComposeViewController()
        
        let composeNav = UINavigationController(rootViewController:composeVC)
        
        present(composeNav, animated: true, completion: nil)
        
    }
    
}


